import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'layout',
    redirect: '/home',
    component: () => import('@/views/layout'),
    children: [
        //首页
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/Home/index'),
        meta: {
          show:true,
          right: true
        }
      },
        //登录
      {
        path: '/login',
        name: 'login',
        component: () => import('@/views/Login/login'),
        meta: {
          show:true,
          right: true
        }
      },
        //商品详情页
      {
        path: '/productDetail',
        name:'productDetail',
        component: () => import('@/views/productDetail/index'),
        meta: {
          show: true,
          right: false
        }
      },
        //购物车页面
      {
        path: '/cart',
        name:'cart',
        component: () => import('@/views/shoppingTrolley/index'),
        meta: {
          show: true,
          right: false
        }
      },
        //商品搜索
      {
        path: '/search',
        name:'search',
        component: () => import('@/views/productSearch/index'),
        meta: {
            show: true,
            right: false
        }
      },
        //用户中心
      {
        path:'/userCenter',
        name:'userCenter',
        component: () => import('@/views/userCenter/userCenter'),
        meta: {
          show: false,
          right: false
        },
        //用户中心的子页面
        children:[
          {
            path:'/userCenter/',
            name:'userInfo',
            component: () => import('@/views/userCenter/userInfo/index')
          },
          {
            path:'/userCenter/recharge',
            name:'recharge',
            component: () => import('@/views/userCenter/recharge/index')
          },
          {
            path:'/userCenter/favorite',
            name:'favorite',
            component: () => import('@/views/userCenter/favorite/index')
          },
          {
            path:'/userCenter/footprint',
            name:'footprint',
            component: () => import('@/views/userCenter/footprint/index')
          },
          {
            path:'/userCenter/address',
            name:'address',
            component: () => import('@/views/userCenter/address/index')
          },
          {
            path:'/userCenter/myOrder',
            name:'myOrder',
            component: () => import('@/views/userCenter/myOrder/index')
          }
        ]
      },
      //商品搜索
      {
        path: '/productClassify',
        name:'productClassify',
        component: () => import('@/views/productClassify/index'),
        meta: {
          show: true,
          right: false
        }
      },
        //订单详情
      {
        path: '/orderDetail',
        name:'orderDetail',
        component: () => import('@/views/order/orderDetail'),
        meta: {
          show: false,
          right: false
        }
      },
        //订单评价
      {
        path: '/orderEvaluate',
        name:'orderEvaluate',
        component: () => import('@/views/order/orderEvaluate'),
        meta: {
          show: false,
          right: false
        }
      },
      //创建订单
      {
        path: '/orderCreation',
        name:'orderCreation',
        component: () => import('@/views/order/orderCreation'),
        meta: {
          show: false,
          right: false
        }
      }
    ]
  },
  //注册
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/Login/register'),
    //meta 控制是否显示 nav header footer 组件
    meta: {
      show:false
    }
  },
  {
    path: '/login1',
    name: 'login1',
    component: () => import('@/views/Login/login1'),
    //meta 控制是否显示 nav header footer 组件
    meta: {
      show:false
    }
  },
    //测试
  {
    path: '/test',
    name: 'test',
    component: () => import('@/views/test')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
